package com.fengke.dao.member.impl;

import java.sql.SQLException;
import java.util.List;

import com.fengke.dao.BaseDaoIbatis;
import com.fengke.dao.member.MemberManager;
import com.fengke.dao.model.MemberModel;
import com.fengke.dao.model.OpenUnionModel;
import com.fengke.dao.model.ProductModel;

public class MemberManagerImpl extends BaseDaoIbatis implements MemberManager {

	public Integer researchMemberListSize(MemberModel memberModel) throws SQLException {
		return (Integer) this.getSqlMapClientTemplate().queryForObject("MemberRepository.researchMemberListSize", memberModel);
	}

	@SuppressWarnings("unchecked")
	public List<MemberModel> researchMemberList(MemberModel memberModel, int offset, int limit) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("MemberRepository.researchMemberList", memberModel, offset, limit);
	}

	@SuppressWarnings("unchecked")
	public List<MemberModel> researchMemberListByProductInfo(ProductModel productModel) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("MemberRepository.researchMemberListByProductInfo", productModel);
	}

	@Override
	public Long createOpenUnion(OpenUnionModel openUnionModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("MemberRepository.createOpenUnion", openUnionModel);
	}

	@Override
	public OpenUnionModel researchOpenUnionByOpenId(OpenUnionModel openUnionModel) throws SQLException {
		return (OpenUnionModel) this.getSqlMapClientTemplate().queryForObject("MemberRepository.researchOpenUnionByOpenId", openUnionModel);
	}

	@Override
	public MemberModel researchMemberByUnionId(MemberModel memberModel) throws SQLException {
		return (MemberModel) this.getSqlMapClientTemplate().queryForObject("MemberRepository.researchMemberByUnionId", memberModel);
	}

	@Override
	public Long createMember(MemberModel memberModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("MemberRepository.createMemberModel", memberModel);
	}

}
